<template>
  <div class="newaddress">
    <van-nav-bar left-arrow title="新增地址" @click-left="handleBackToMyself"></van-nav-bar>
    <van-address-edit
      :area-list="areaList"
      show-postal
      show-delete
      show-set-default
      show-search-result
      :search-result="searchResult"
      @save="onSave"
      @delete="onDelete"
      @change-detail="onChangeDetail"
    />
  </div>
</template>

<script>
export default {
  data() {
    return {
      areaList: {
        province_list: {
          110000: "北京市",
          610000: "陕西省"
        },
        city_list: {
          610100: "西安市",
          110100: "北京市"
        },
        county_list: {
          610101: "雁塔区",
          610102: "碑林区",
          610105: "高新区",
          610106: "灞桥区",
          620101: "莲湖区",
          620102: "新城区",
          620103: "长安区",
          620104: "未央区",
          620105: "临潼区",
          110101: "东城区",
          110102: "西城区",
          110105: "朝阳区",
          110106: "丰台区",
          110107: "石景山区",
          110108: "海淀区",
          110109: "门头沟区",
          110111: "房山区",
          110112: "通州区",
          110113: "顺义区",
          110114: "昌平区",
          110115: "大兴区",
          110116: "怀柔区",
          110117: "平谷区",
          110118: "密云区",
          110119: "延庆区"
        }
      },
      searchResult: []
    };
  },

  methods: {
    handleBackToMyself() {
      this.$router.go(-1);
    },
    onSave() {
      Toast("save");
    },
    onDelete() {
      Toast("delete");
    },
    onChangeDetail(val) {
      if (val) {
        this.searchResult = [
          {
            name: "黄龙万科中心",
            address: "杭州市西湖区"
          }
        ];
      } else {
        this.searchResult = [];
      }
    }
  }
};
</script>
<style lang='stylus' scoped></style>